package com.ydche.util;

import com.ydche.idl_output.RequestException;
import org.apache.thrift.TException;


public class MyException {
     public static RequestException makeException(String msg, String code) {
        RequestException e = new RequestException();
        e.setCode(code);
        e.setMsg(msg);
        return e;
    }

    public static RequestException makeException(String msg) {
        RequestException e = new RequestException();
        e.setCode("0001");
        e.setMsg(msg);
        return e;
    }

    public static void handleThriftException(Exception e) {
        e.printStackTrace();
        if(e instanceof RequestException) {
            RequestException re = (RequestException)e;
            System.out.println("RequestException,msg=" + re.getMsg());
        } else if (e instanceof TException) {
            TException te = (TException)e;
            System.out.println("TException,msg=" + te.toString());
        } else {
            System.out.println("not thrift exception,msg=" + e.toString());
        }
    }


}
